﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Bll;
using AspNetCs.Model;
using AspNetCs.Common;
using AspNetCs.Config;
using System.Data;
using System.Data.SqlClient;
using AspNetCs.Enumerations;


public partial class Master_Admin_ManageUsers :Admin_BasePage
{
    protected City city = new City();
    protected Province province = new Province();
    Users bll = User_Bll.CreateNew;
    protected void Page_Load(object sender, EventArgs e)
    {
        IsExit();
        if (!IsPostBack)
        {
            dataBind();
        }
    }



    protected void dataBind()
    {
        string cmdText = "select *from users where UserDel=0 order by userid desc";
        AspNetCs.Common.DataPagesOperate operate = new DataPagesOperate();

        operate.BindRepeater(cmdText, AspNetPager1, "userid desc", "userid", rptNetMuList);


    }


    protected void rptNetMuList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        LinkButton lbtn = null;
        try
        {
            int count = 0;
            string id = "";
            int NetMuId = 0;
            if (e.CommandName == "Modify")
            {
                lbtn = e.Item.FindControl("btn_modify") as LinkButton;
                id = lbtn.CommandArgument;
                NetMuId = Convert.ToInt32(id);
                if (lbtn.Text == "锁定")
                {
                    bll.UserLock(NetMuId);
                }
                else if (lbtn.Text == "取消")
                {
                    bll.UserUnLock(NetMuId);
                }
                dataBind();

            }
            else if (e.CommandName == "delete")
            {
                lbtn = e.Item.FindControl("btn_del") as LinkButton;
                id = lbtn.CommandArgument;
                NetMuId = Convert.ToInt32(id);
                bool bo = false;

                count = bll.Del(NetMuId);
                bo = count > 0 ? true : false;
                if (bo)
                {
                    showMessage("deleteSucce", "删除成功");
                    dataBind();
                }
                else
                {
                    showMessage("deleteFaith", "删除失败");
                    dataBind();
                }
            }
        }
        catch (Exception ex)
        {
            new CustomException(ex);
        }
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        dataBind();
    }
}
